﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CreditCreater.ascx.cs"
    Inherits="CreditCreater" %>
<table>
    <tr>
        <td>
            <asp:Label ID="NameLabel" runat="server" AssociatedControlID="Name">Название:</asp:Label>
        </td>
        <td>
            <asp:TextBox ID="Name" MaxLength="30" runat="server" CssClass="textEntry"></asp:TextBox>
            <asp:RequiredFieldValidator ID="NameValidReq" ControlToValidate="Name" Text="*" ForeColor="Red"
                SetFocusOnError="true" runat="server" ValidationGroup="RegisterCreditValidationGroup"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="NameValidReqValidator" ControlToValidate="Name"
                Text="Введите название (2-30)" ForeColor="Red" Display="Dynamic" ValidationExpression="^([a-zA-ZА-ЯЁа-яё0-9 '-_&,().]{2,30})+$"
                runat="server" ValidationGroup="RegisterCreditValidationGroup" />
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="MinValueLabel" runat="server" AssociatedControlID="MinValue">Минимальная сумма:</asp:Label>
        </td>
        <td>
            <asp:TextBox ID="MinValue" MaxLength="12" runat="server" CssClass="textEntry" OnTextChanged="MinValue_TextChanged"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="MinValue"
                Display="Static" ErrorMessage="*" ForeColor="Red" SetFocusOnError="true" runat="server"
                ValidationGroup="RegisterCreditValidationGroup"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator runat="server" ID="MinValueValidator" ControlToValidate="MinValue"
                Text="Введите целое положительное число." ForeColor="Red" ValidationExpression="(^[1-9][0-9]*$)"
                ValidationGroup="RegisterCreditValidationGroup" />
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="MaxValueLabel" runat="server" AssociatedControlID="MaxValue">Максимальная сумма:</asp:Label>
        </td>
        <td>
            <asp:TextBox ID="MaxValue" MaxLength="12" runat="server" CssClass="textEntry"></asp:TextBox>
            <asp:RequiredFieldValidator ID="AdminValidator" ControlToValidate="MaxValue" Display="Static"
                ErrorMessage="*" ForeColor="Red" SetFocusOnError="true" runat="server" ValidationGroup="RegisterCreditValidationGroup"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator runat="server" ID="MaxValueValidator" ControlToValidate="MaxValue"
                Text="Введите целое положительное число." ForeColor="Red" ValidationExpression="(^[1-9][0-9]*$)"
                ValidationGroup="RegisterCreditValidationGroup" />
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="MinTermLabel" runat="server" AssociatedControlID="MinTerm">Минимальный срок:</asp:Label>
        </td>
        <td>
            <asp:TextBox ID="MinTerm" MaxLength="3" runat="server" CssClass="textEntry"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="MinTerm"
                Display="Static" ErrorMessage="*" ForeColor="Red" SetFocusOnError="true" runat="server"
                ValidationGroup="RegisterCreditValidationGroup"></asp:RequiredFieldValidator>
            <asp:RangeValidator ID="MinTermRangeValidator" runat="server" ControlToValidate="MinTerm"
                Text="Введите значение от 1 до 900 мес." ForeColor="Red" Type="Integer" MinimumValue="1"
                MaximumValue="900" ValidationGroup="RegisterCreditValidationGroup" />
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="MaxTermLabel" runat="server" AssociatedControlID="MaxTerm">Максимальный срок:</asp:Label>
        </td>
        <td>
            <asp:TextBox ID="MaxTerm" MaxLength="3" runat="server" CssClass="textEntry"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" ControlToValidate="MaxTerm"
                Display="Static" ErrorMessage="*" ForeColor="Red" SetFocusOnError="true" runat="server"
                ValidationGroup="RegisterCreditValidationGroup"></asp:RequiredFieldValidator>
            <asp:RangeValidator ID="MaxTermRangeValidator" runat="server" ControlToValidate="MaxTerm"
                Text="Введите значение от 1 до 900 мес." ForeColor="Red" Type="Integer" MinimumValue="1"
                MaximumValue="900" ValidationGroup="RegisterCreditValidationGroup" />
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="CurrencySelectorLabel" runat="server" AssociatedControlID="GridViewCurrencySelector">Валюты:</asp:Label>
        </td>
        <td>
            <asp:GridView ID="GridViewCurrencySelector" Width="325px" runat="server" AutoGenerateColumns="False"
                DataKeyNames="CurrencyID" DataSourceID="SqlDataSourceCurrency">
                <Columns>
                    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                    <asp:BoundField DataField="CurrencyID" HeaderText="CurrencyID" InsertVisible="False"
                        ReadOnly="True" SortExpression="CurrencyID" Visible="False" />
                    <asp:TemplateField HeaderText="Выбрать">
                        <ItemTemplate>
                            <asp:CheckBox ID="isSelectedCurrency" runat="server" OnCheckedChanged="isSelectedCurrencyChanged"
                                AutoPostBack="true"></asp:CheckBox>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Процент">
                        <ItemTemplate>
                            <asp:TextBox ID="currencyPercentageTextBox" runat="server" Enabled="false"> </asp:TextBox>
                             <asp:RequiredFieldValidator ID="ReqCurrencyValidator" ControlToValidate="currencyPercentageTextBox" Display="Static"
	                ErrorMessage="*" ForeColor="Red" SetFocusOnError="true" Enabled="false" runat="server"  ValidationGroup="RegisterCreditValidationGroup"></asp:RequiredFieldValidator>
	            <asp:RegularExpressionValidator runat="server" Enabled="false" ID="CurrencyValidator" ControlToValidate="currencyPercentageTextBox"
	                Text="Введите целое положительное число." ForeColor="Red" ValidationExpression="(^[1-9][0-9]*$)"
	                 ValidationGroup="RegisterCreditValidationGroup" />
                           
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <asp:SqlDataSource ID="SqlDataSourceCurrency" runat="server" ConnectionString="<%$ ConnectionStrings:BankDBConnectionString %>"
                SelectCommand="SELECT [Name], [CurrencyID] FROM [Currency]"></asp:SqlDataSource>
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label1" runat="server" AssociatedControlID="GridViewCurrencySelector">Формы выдачи:</asp:Label>
        </td>
        <td>
            <asp:GridView ID="FacilitiesFormGridView" Width="325px" runat="server" AutoGenerateColumns="False"
                DataKeyNames="CreditFacilitiesFormId" DataSourceID="SqlDataSourceFacilitiesForm">
                <Columns>
                    <asp:BoundField DataField="CreditFacilitiesFormId" HeaderText="CreditFacilitiesFormId"
                        SortExpression="CreditFacilitiesFormId" ReadOnly="True" Visible="False" />
                    <asp:BoundField DataField="Name" SortExpression="Name" />
                    <asp:TemplateField HeaderText="Выбрать">
                        <ItemTemplate>
                            <asp:CheckBox ID="isSelectedForm" runat="server" AutoPostBack="true"></asp:CheckBox>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <asp:SqlDataSource ID="SqlDataSourceFacilitiesForm" runat="server" ConnectionString="<%$ ConnectionStrings:BankDataBaseConnectionString %>"
                SelectCommand="SELECT [CreditFacilitiesFormId], [Name] FROM [CreditFacilitiesForm]">
            </asp:SqlDataSource>
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="CommisionPercentageLabel" runat="server" AssociatedControlID="CommisionPercentage">Процент комиссии %:</asp:Label>
        </td>
        <td>
            <asp:TextBox ID="CommisionPercentage" MaxLength="10" runat="server" CssClass="textEntry"></asp:TextBox>
            <asp:RequiredFieldValidator ID="PercentFieldValidator" ControlToValidate="CommisionPercentage"
                Display="Static" ErrorMessage="*" ForeColor="Red" SetFocusOnError="true" runat="server"
                ValidationGroup="RegisterCreditValidationGroup"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="PercentRegularExpressionValidator" runat="server"
                ControlToValidate="CommisionPercentage" ValidationGroup="RegisterCreditValidationGroup"
                Text="Введите процент от 1,00 % до 1000 %" ForeColor="Red" ValidationExpression="^(1000(\,0{0,2}?)?$|([1-9]|[1-9][0-9])(\,\d{1,2})?)$"></asp:RegularExpressionValidator>
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="AdvancedRepaymentLabel" runat="server" AssociatedControlID="AdvancedRepayment">Возможность досрочного погашения:</asp:Label>
        </td>
        <td>
            <asp:DropDownList ID="AdvancedRepayment" runat="server">
                <asp:ListItem Selected="True" Value="1">Да</asp:ListItem>
                <asp:ListItem Value="0">Нет</asp:ListItem>
            </asp:DropDownList>
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="ActiveCreditLabel" runat="server" AssociatedControlID="CheckBoxActiveCredit">Активный:</asp:Label>
        </td>
        <td>
            <asp:CheckBox ID="CheckBoxActiveCredit" runat="server" Enabled="false" Checked="true"
                OnCheckedChanged="CheckBoxActiveCredit_CheckedChanged" AutoPostBack="true" />
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="DescriptionLabel" runat="server" AssociatedControlID="Description">Описание:</asp:Label>
        </td>
        <td>
            <asp:TextBox ID="Description" MaxLength="100" runat="server" CssClass="textEntry" TextMode="MultiLine"
                Height="58px" Width="317px"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator22" ControlToValidate="Description"
                Display="Static" ErrorMessage="*" ForeColor="Red" SetFocusOnError="true" runat="server"
                ValidationGroup="RegisterCreditValidationGroup"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
                ControlToValidate="Description" ValidationGroup="RegisterCreditValidationGroup"
                Text="Максимум 500 символов" ForeColor="Red" ValidationExpression="^[\s\S]{0,500}$"></asp:RegularExpressionValidator>
        </td>
        <td>
            &nbsp;
        </td>
    </tr>
</table>
<p>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:Button ID="AddCreditButton" runat="server" Text="Добавить кредит" OnClick="AddCreditButton_Click"
        ValidationGroup="RegisterCreditValidationGroup" Style="text-align: right" />
         &nbsp;&nbsp;&nbsp;&nbsp;
	      <asp:Label ID="ErrorLabel" runat="server" Text="" ForeColor="Red"></asp:Label>
</p>
